<?php


namespace App\Http\Controllers\Admin;


use App\Model\Store;
use App\Tool\Json;

class StoreController extends AuthCheckController
{

    function updateStore(){

        $id=request()->input('id');

        $post=request()->input();

        $post['province']=$post['areaText'][0];
        $post['city']=$post['areaText'][1];
        $post['area']=$post['areaText'][2];

        Store::updateOrCreate(['id'=>$id],$post);


    }


    function storeList(){

        $list=Store::orderBy('id','desc');


        return Json::code(1,'success',paginate($list,request()->input('p',1)));

    }


    function detail(){



        $data=Store::find(request()->input('id'));

        return Json::code(1,'success',$data);
    }

    function deleted(){


        $id=(int)request()->input('id');

        Store::destroy($id);

        return Json::code(1,'success');

    }

}
